﻿#include "stdafx.h"
#include "XGifIntParser.h"

#include "XBSTR.h"
#include "StrUtil.h"
#include "Util.h"
#include "IXGif.h"

#include "ParseHelper.h"


CXGifIntParser::CXGifIntParser() : CXIntParserBase(&TIntCreateControl<IXGif>)
{
    ;
}

CXGifIntParser::~CXGifIntParser()
{
    ;
}

// 填充属性
BOOL CXGifIntParser::FillAttr(IN IXConfigNode* pNode, IN IXControl* pControl)
{
    BOOL bResult = m_ParentParser.FillAttr(pNode, pControl);
    if(!bResult)
        return bResult;

    XBSTR bstrTemp;
    LONG lTemp;

    IXGif* pGif = Util::QueryIntf<IXGif>(pControl);
    if(pGif == NULL)
        return FALSE;

    // XNC
    if(SUCCEEDED(pNode->GetValue(_T("xnc"), &bstrTemp)))
    {
        pGif->put_Gif(bstrTemp);
    }

    // PlayMode
    if(SUCCEEDED(pNode->GetValue(_T("mode"), &bstrTemp)))
    {
        if(_tcsicmp(bstrTemp, _T("default")) == 0)
            pGif->SetPlayMode(GPM_Default);
        else if(_tcsicmp(bstrTemp, _T("fixed")) == 0)
            pGif->SetPlayMode(GPM_Fixed);
    }

    // FixedInterval
    if(SUCCEEDED(pNode->GetValue(_T("fixedInt"), &lTemp)))
    {
        pGif->SetFixedInterval(lTemp);
    }

    return bResult;
}
